This documentation describes the step-by-step process to prevent Ubuntu 24.04 from automatically powering off when idle on AC power.
gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
# Output: 'nothing'
gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type
# Output: 'nothing'
sudo systemctl status sleep.target
# Output:
# ○ sleep.target - Sleep
# Loaded: loaded (/usr/lib/systemd/system/sleep.target; static)
# Active: inactive (dead)
# Docs: man:systemd.special(7)
sudo grep -E "Handle|Idle" /etc/systemd/logind.conf
# Output:
# #HandlePowerKey=poweroff
# #HandlePowerKeyLongPress=ignore
# #HandleRebootKey=reboot
# #HandleRebootKeyLongPress=poweroff
# #HandleSuspendKey=suspend
# #HandleSuspendKeyLongPress=hibernate
# #HandleHibernateKey=hibernate
# #HandleHibernateKeyLongPress=ignore
# #HandleLidSwitch=suspend
# #HandleLidSwitchExternalPower=suspend
# #HandleLidSwitchDocked=ignore
# #IdleAction=ignore
# #IdleActionSec=30min
# #StopIdleSessionSec=infinity
systemctl list-timers --all | grep -i shutdown
# Output: (no output)
systemctl list-unit-files | grep -i suspend
# Output:
# nvidia-suspend.service enabled enabled
# systemd-suspend-then-hibernate.service static -
# systemd-suspend.service static -
# suspend-then-hibernate.target static -
# suspend.target static -
gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout
# Output: 900
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
killall -HUP gnome-settings-daemon
After these steps, Ubuntu 24.04 should no longer automatically power off when idle on AC power.
slimani@slimani-Latitude-E5570:~$ gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
'nothing'
slimani@slimani-Latitude-E5570:~$ gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type
'nothing'
slimani@slimani-Latitude-E5570:~$ sudo systemctl status sleep.target
○ sleep.target - Sleep
Loaded: loaded (/usr/lib/systemd/system/sleep.target; static)
Active: inactive (dead)
Docs: man:systemd.special(7)
slimani@slimani-Latitude-E5570:~$ sudo grep -E "Handle|Idle" /etc/systemd/logind.conf
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#IdleAction=ignore
#IdleActionSec=30min
#StopIdleSessionSec=infinity
slimani@slimani-Latitude-E5570:~$ systemctl list-timers --all | grep -i shutdown
slimani@slimani-Latitude-E5570:~$ systemctl list-unit-files | grep -i suspend
nvidia-suspend.service enabled enabled
systemd-suspend-then-hibernate.service static -
systemd-suspend.service static -
suspend-then-hibernate.target static -
suspend.target static -
slimani@slimani-Latitude-E5570:~$ gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout
900
slimani@slimani-Latitude-E5570:~$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
slimani@slimani-Latitude-E5570:~$ killall -HUP gnome-settings-daemon
gnome-settings-daemon: no process found
slimani@slimani-Latitude-E5570:~$ systemctl --user restart gnome-session.target
Failed to restart gnome-session.target: Operation refused, unit gnome-session.target may be requested by dependency only (it is configured to refuse manual start/stop).
See user logs and 'systemctl --user status gnome-session.target' for details.
slimani@slimani-Latitude-E5570:~$